package com.eexcel.contributor.implementation;

import com.eexcel.workbench.IFormula;

/**
 * Defines the implementation for the extension point defined by workbench plug-in
 * @author Simão Fernandes
 * @version %I %, %G%
 * @since 1.0
 */
public class Formula implements IFormula {

	private final String FIBONACCI = "fib";
	private final String FACTORIAL = "fact";
	
	/**
	 * Gets the name of the functions provided by the extension
	 * @return Result
	 */
	@Override
	public String[] getFunctions() {
		return new String[] { FIBONACCI, FACTORIAL };
	}
	
	/**
	 * Applies the provided function
	 * @param function Function name
	 * @param operando Operand
	 */
	@Override
	public int calculate(String function, int operando) {
		
		switch (function) {
		case FIBONACCI:
			return Fibonacci.doIt(operando);
		case FACTORIAL:
			return Factorial.doIt(operando);
		default:
			return -1;	//TODO handle default
		}
	}

}
